﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using DTO;

namespace CungMuaC5
{
    public static class SessionExt
    {
        public static DTO_TaiKhoan GetCurrentUser(this HttpSessionState session)
        {
            return session["CurrentUser"] as DTO_TaiKhoan;
        }

        public static void SetCurrentUser(this HttpSessionState session, DTO_TaiKhoan UserAccount)
        {
            session["CurrentUser"] = UserAccount;
            session["IsLogin"] = 1;
        }

        public static void SetLogOutState(this HttpSessionState session)
        {
            session["CurrentUser"] = null;
            session["IsLogin"] = 0;
        }
		
		public static int IsLogin(this HttpSessionState session)
        {
            return (int)session["Login"];
        }

        public static void SetReceiver(this HttpSessionState session, DTO_NguoiNhan User)
        {
            session["Receiver"] = User;
        }

        public static DTO_NguoiNhan GetReceiver(this HttpSessionState session)
        {
            return session["Receiver"] as DTO_NguoiNhan;
        }

        public static void SetDonHang(this HttpSessionState session, DTO_DonHang User)
        {
            session["DonHang"] = User;
        }

        public static DTO_DonHang GetDonHang(this HttpSessionState session)
        {
            return session["DonHang"] as DTO_DonHang;
        }

        public static void SetLoginTurnPage(this HttpSessionState session,int value)
        {
            session["LoginTurnPage"] = value;
        }
        
        public static int GetLoginTurnPage(this HttpSessionState session)
        {
            if (session["LoginTurnPage"] == null)
                return 0;
            else
                return (int)session["LoginTurnPage"];
        }
        public static void SetDiaDiem(this HttpSessionState session, int value)
        {
            session["DiaDiem"] = value;
        }

        public static int GetDiaDiem(this HttpSessionState session)
        {
            if (session["DiaDiem"] == null)
                return -1;
            else
                return (int)session["DiaDiem"];
        }
    }
}